<div class="page-header">
	<h1>Tin tức</h1>
</div>
<?php
//set "code" for searches
if(empty($code))
{
	$code = '';
}
else
{
	$code = '/'.$code;
}
function sort_url($lang, $by, $sort, $sorder, $code, $admin_folder)
{
	if ($sort == $by)
	{
		if ($sorder == 'asc')
		{
			$sort	= 'desc';
			$icon	= ' <i class="icon-chevron-up"></i>';
		}
		else
		{
			$sort	= 'asc';
			$icon	= ' <i class="icon-chevron-down"></i>';
		}
	}
	else
	{
		$sort	= 'asc';
		$icon	= '';
	}
	$return = site_url($admin_folder.'/products/index/'.$by.'/'.$sort.'/'.$code);
	echo '<a href="'.$return.'">'.lang($lang).$icon.'</a>';
}
function set_value_active($active){
	if($active == 1) return "Bật";
	else			 return "Tắt";	
}
echo $paging;
$url_form = !empty($page_index)?$this->config->item('admin_folder').'/news/bulk_save/'.$page_index:$this->config->item('admin_folder').'/news/bulk_save';
echo form_open($url_form, array('id'=>'bulk_form'));?>
	<table class="table table-striped">
		<thead>
			<tr>
				<th>ID</th>
				<th>Tên tin</th>
                <th>Mục tin</th>
				<th>Trạng thái</th>
				<th>
					<span class="btn-group pull-right">
						<button class="btn" href="#"><i class="icon-ok"></i> Lưu tất cả </button>
						<a class="btn" style="font-weight:normal;"href="<?php echo site_url($this->config->item('admin_folder').'/news/edit');?>"><i class="icon-plus-sign"></i>Tạo mới</a>
					</span>
				</th>
			</tr>
		</thead>
		<tbody>
	<?php echo (count($model) < 1)?'<tr><td style="text-align:center;" colspan="7"> Hiện không có tin tức</td></tr>':''?>
	<?php foreach ($model as $item):?>
			<tr>
            	<td> <?php echo $item->id?></td>
				<td><?php echo form_input(array("name"=>"title[".$item->id."]","value"=>$item->title,"class"=>"span5"));?></td>
				<td><?php echo form_dropdown("news_category[".$item->id."]",$cat_select,$item->cat_id,"class='span2'");?></td>
				<td>
					<?php
					 	$options = array(
			                  '1'	=> "Bật",
			                  '0'	=> "Tắt"
			                );

						echo form_dropdown('active['.$item->id.']', $options,set_value($item->active),'class="span2"');
					?>
				</td>
				<td>
					<span class="btn-group pull-right">
						<a class="btn" href="<?php echo  site_url($this->config->item('admin_folder').'/news/edit/'.$item->id);?>"><i class="icon-pencil"></i>  <?php echo lang('edit');?></a>
						<a class="btn" href="<?php echo  site_url($this->config->item('admin_folder').'/news/copy_data/'.$item->id.'/'.$page_index);?>"><i class="icon-share-alt"></i>Copy</a>
						<a class="btn btn-danger" href="<?php echo site_url($this->config->item('admin_folder').'/news/delete/'.$item->id."/".$page_index);?>" onclick="return areyousure();"><i class="icon-trash icon-white"></i> <?php echo lang('delete');?></a>
					</span>
				</td>
			</tr>
	<?php endforeach; ?>
		</tbody>
	</table>
</form>
<script language="javascript">
	$(".btn-danger").click(function(){
		return confirm("Bạn có thật sự muốn xóa");
	});
</script>